package com.sky.controller.user;

import com.sky.context.BaseContext;
import com.sky.dto.AppealDTO;
import com.sky.dto.AppealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.AppealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userAppealController")
@RequestMapping("/user/appeal")
@Api(tags = "申诉相关接口")
@Slf4j
public class AppealController {
    @Autowired
    private AppealService appealservice;
    /**
     * 个人分页查询
     * @param pageQuery
     * @return
     */
    @RequiresPermissions("普通用户")
    @GetMapping("/page")
    @ApiOperation("个人申诉记录分页查询")
    public Result<PageResult> page(AppealPageQueryDTO pageQuery) {
        pageQuery.setId(BaseContext.getCurrentId());
        PageResult pageResult = appealservice.mypageQuery(pageQuery);
        return Result.success(pageResult);
    }
     //违法记录申诉
    @RequiresPermissions("普通用户")
    @PostMapping()
    @ApiOperation(value = "违法记录申诉")
    public Result appeal(@RequestBody AppealDTO appealDTO) {
        appealservice.appeal(appealDTO);
        return Result.success();
    }

}
